#include <stdio.h>
#include <net/ethernet.h>
#include "util.h"

size_t strlcpy(char *dst, const char *src, size_t n)
{
	char *s;

	for (s = dst; n > 0 && *src != '\0'; --n)
		*s++ = *src++;

	*s++ = '\0';
	return (s - dst - 1);
}

void print_mac_address(const char *mac)
{
	int i;
	for (i = 0; i < ETH_ALEN - 1; i++) {
		printf("%02x-", (unsigned int)mac[i] & 0xFF);
	}
	printf("%02x\n", (unsigned int)mac[i] & 0xFF);
	return;
}

void print_frame_data(void *frame, int len)
{
	int i;
	unsigned char *tmp = (unsigned char *)frame;

	for (i = 0; i < len; i++) {
		printf("%02x ",  (unsigned int)(*tmp));
		if (0xF == (i & 0xF)) {
			printf("\n");
		}
		tmp++;
	}
	printf("\n");
}
